﻿using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Destroys the direct message specified in the required ID parameter.
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.DirectMessageToolbox.bmp")]
    [Designer(typeof(DeleteDirectMessageDesigner))]
    [Description("Destroys the direct message specified in the required ID parameter.")]
    public class DeleteDirectMessage : TwitterOperationInvoker<DirectMessage>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DeleteDirectMessage"/> class.
        /// </summary>
        public DeleteDirectMessage()
            : base("DeleteDirectMessage")
        {
            Message = new InArgument<DirectMessage>();
        }

        /// <summary>
        ///  The Direct message to delete.
        ///  <remarks>
        ///  Required Argument
        /// </remarks>
        /// </summary>
        /// <value>
        ///  The Direct message to delete.
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [Description("The Direct message to delete.")]
        [RequiredArgument]
        public InArgument<DirectMessage> Message { get; set; }

        [Browsable(false)]
        public InArgument<long> MessageID { get; set; }

        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(NativeActivityMetadata metadata)
        {
            RuntimeArgument messageArgument = new RuntimeArgument("Message", typeof(DirectMessage), ArgumentDirection.In, true);
            metadata.Bind(Message, messageArgument);
            metadata.AddArgument(messageArgument);

            RuntimeArgument messageIDArgument = new RuntimeArgument("MessageID", typeof(long), ArgumentDirection.In, false);
            metadata.Bind(MessageID, messageIDArgument);
            metadata.AddArgument(messageIDArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(NativeActivityContext context)
        {
            Parameters.Clear();

            MessageID.Set(context, Message.Get(context).ID);
            Parameters.Add("id", MessageID);

            base.Execute(context);
        }


    }
}
